home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CONTRSRC.ZIP / SRC / TYPEONE / TRANSF.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-11-12  |  25.3 KB  |  927 lines

  1.  
  2. ;**************************************************
  3. ; TRANSFORMATION (C) 1994 Type One / TFL-TDV Prod.
  4. ;**************************************************
  5.  
  6. INCLUDE PDFIK.INC ; DataFile Manager
  7. INCLUDE VIDEO.INC ; Flamoot VGA SetUp
  8. INCLUDE PLAYINFO.INC ; Player structures
  9. INCLUDE KEYBOARD.INC ; Keyboard macros
  10.  
  11. ;-----------------------------------------
  12. ; Déclaration modèle mémoire
  13. .386
  14. DGROUP GROUP _DATA,_BSS
  15. TRANS_TEXT  SEGMENT DWORD PUBLIC USE16 'CODE'
  16.        ASSUME CS:TRANS_TEXT,DS:DGROUP
  17. TRANS_TEXT  ENDS
  18. _DATA  SEGMENT DWORD PUBLIC USE16 'DATA'
  19. _DATA  ENDS
  20. _BSS   SEGMENT DWORD PUBLIC USE16 'BSS'
  21. _BSS   ENDS
  22. ;-----------------------------------------
  23.  
  24. _DATA SEGMENT
  25.  
  26. ; Quelques constantes bien utiles ......
  27.  
  28. Larg = 160       ; hauteur de l'écran en pixels
  29. Haut = 67        ; largeur de l'écran en pixels
  30. Windowx = 160    ; largeur fenetre
  31. Windowy = 67     ; hauteur fenetre
  32.  
  33. Screen1 = 0
  34. Screen2 = (Larg*Haut/4)
  35. Screen3 = (Larg*Haut/4)*2
  36.  
  37. ;---------------------------------------------
  38.  
  39.  
  40. ;-- donnees pattern --
  41. EXTRN _Datafile  : BYTE
  42. EXTRN _OfsinDta  : DWORD
  43. Picname   BYTE 'magic05.raw',0
  44. Picparam  PARAM_STRUC<2,_DATA,OFFSET _Datafile,OFFSET Picname,0,0,0,,,0>
  45.  
  46. EVEN
  47. ; transformation parameters
  48. Yptr   WORD 0          ; pointeur sinus en y
  49. Xptr   WORD 0          ; pointeur sinus en x
  50. XSptr  WORD 0          ; pointeur sinus en x-scaling
  51.  
  52. cumul_step_lo DD 0
  53. cumul_step_hi DD 0
  54. cumul_old_lo  DD 0
  55. cumul_old_hi  DD 0
  56.  
  57.  
  58. EXTRN _BlackPal: BYTE
  59. EXTRN _WhitePal: BYTE
  60.  
  61. _DATA    ENDS
  62.  
  63. ;données non initialisées
  64. _BSS SEGMENT
  65.  
  66. EXTRN _FrameCounter     : WORD
  67. EXTRN _SinusTbl         : WORD ; table sinus*256 pour transformation
  68. EXTRN _StartAdr         : WORD
  69. EXTRN _WorkAdr          : WORD
  70. EXTRN _NextAdr          : WORD
  71. EXTRN _Triple           : WORD
  72. EXTRN _SyncFlag         : WORD
  73. EXTRN _TmpPal           : BYTE
  74. EXTRN _FadeON           : WORD
  75. EXTRN _VGAcompatible    : WORD
  76. ;!!!!!!!!!! synchro avec music !!!!!!!!!!!!
  77. EXTRN _MP               : DWORD ; extern ModulePlayer * MB
  78. EXTRN _ReplayInfo       : mpInformation
  79.  
  80. ;---- param pour synchro avec zizik ----
  81. EVEN
  82. DebSong  WORD ?
  83. FinSong  WORD ?
  84.  
  85.  
  86. EVEN
  87. Picseg    WORD ?        ; ptr vers segment pattern
  88. TabSeg    WORD ?        ; ptr vers segment curves table
  89. Timeleft  WORD ?        ; temps restant pour execution
  90.  
  91. Dest DW ?
  92.  
  93. FadeFlag WORD ?        ; flag pour fading
  94. FadePtr1 WORD 2 DUP(?) ; ptr sur palette a fader
  95. FadePtr2 WORD 2 DUP(?)
  96. Delai    WORD ?
  97.  
  98. Termine  WORD ?        ; flag pour terminer !!!
  99.  
  100. CurStep WORD ?         ; current step !!!
  101.  
  102.  
  103. _BSS ENDS
  104.  
  105. TRANS_TEXT SEGMENT
  106.      PUBLIC _StartTransf
  107.      EXTRN _AveragePAL : FAR
  108.  
  109.  
  110. ; Point d'entrée de l'intro !!!!!
  111. ;---------------------------------
  112. ALIGN
  113. EVEN
  114. _StartTransf PROC FAR
  115.  
  116.          push    bp                  ; bâtit le cadre de pile
  117.          mov     bp,sp
  118.          
  119.          pushad
  120.          MPUSH ds,es,fs,gs
  121.  
  122.          STARTUP
  123. ;------- recuperer parametres sur le stack !!!! --------
  124.  
  125.          mov     ax,WORD PTR ss:[bp+6]  ; debut pos
  126.          shl     eax,14        
  127.          or      ax,WORD PTR ss:[bp+8]  ; debut row
  128.          or      ah,al
  129.          shr     eax,8
  130.          mov     DebSong,ax
  131.          mov     ax,WORD PTR ss:[bp+10] ; fin pos
  132.          shl     eax,14 
  133.          or      ax,WORD PTR ss:[bp+12] ; fin row
  134.          or      ah,al
  135.          shr     eax,8
  136.          mov     FinSong,ax
  137.          xor     eax,eax
  138. ;-------------------------------------------------------
  139.  
  140.  
  141.          cmp     _VGAcompatible,0
  142.          je      @F 
  143.          push    m160x67x256c        ; set 7-mode if full VGA compatible
  144.          jmp     FullVGA
  145. @@:      push    m320x67x256c
  146. FullVGA: call    _SetVGA
  147.          add     sp,2
  148.  
  149.          STARTUP
  150. ;--------------------------------------
  151.          call    Transf              ; !!!!! Transformation part !!!!!
  152. ;--------------------------------------
  153.  
  154.          mov  ax,0a000h              ; clear screen
  155.          mov  es,ax
  156.          xor  eax,eax
  157.          xor  di,di
  158.          mov  cx,65536/4
  159.          rep  stosd
  160.  
  161.          MPOP ds,es,fs,gs
  162.          popad
  163.          nop
  164.  
  165.          leave                       ; restore stack
  166.                                      ; mov sp,bp + pop bp
  167.          retf
  168.  
  169. _StartTransf ENDP
  170.  
  171.  
  172. ;==============================================================================
  173. ;============================ Transf part =====================================
  174. ;==============================================================================
  175. ALIGN
  176. EVEN
  177. Transf PROC NEAR
  178.  
  179. NEXTSTEP MACRO
  180.         LOCAL lbl1
  181.  
  182. ;------------ FrameCounter manip ------------
  183.         MPUSH  eax,ebx,ecx,edx
  184.  
  185.         mov    cx,_FrameCounter
  186.         test   cx,cx
  187.         jnz    lbl1
  188.         mov    cx,1
  189.  
  190. lbl1:   xor    eax,eax
  191.         mov    ah,cl ; frame*256
  192.        ; mov    ax,256 ;307              ; 1.2*256 = factor
  193.        ; mul    cx
  194.  
  195.         mov    ecx,cumul_step_lo   ; save old cumulated step (64 bits)
  196.         mov    cumul_old_lo,ecx
  197.         mov    ecx,cumul_step_hi
  198.         mov    cumul_old_hi,ecx   
  199.      
  200.         add    cumul_step_lo,eax   ; multiprecision
  201.         adc    cumul_step_hi,0
  202.  
  203.         mov    ecx,cumul_step_hi
  204.         mov    eax,cumul_step_lo
  205.         shrd   eax,ecx,8           ; / 256
  206.         mov    edx,cumul_old_hi
  207.         mov    ebx,cumul_old_lo
  208.         shrd   ebx,edx,8
  209.  
  210.         sub    eax,ebx
  211. ;        sbb    ecx,edx
  212.  
  213.         mov    CurStep,ax  ; CurStep = factor * FrameCounter
  214.  
  215.         mov    _FrameCounter,0
  216.  
  217.         MPOP   eax,ebx,ecx,edx
  218. ;--------------------------------------------
  219.  
  220. ENDM
  221.  
  222.  
  223. ;------------------------------------------------------------------------------
  224.  
  225.          pushad
  226.  
  227.          mov     eax,_OfsinDta         ; OFFSET in Datafile
  228.          mov     Picparam.OfsInPdf,eax
  229.          mov     ax,_DATA              ; prepare for PDFIK call
  230.          mov     es,ax
  231.          mov     bx,OFFSET Picparam
  232.          pusha
  233.          call    PDFIK_ASM             ; call function 2 (extract+alloc)
  234.          popa
  235.          mov     ax,Picparam.BufSeg ; where is the file in mem ?
  236.          mov     Picseg,ax
  237.  
  238.          push    ds
  239.          push    es
  240.          mov     ax,Picseg
  241.          mov     ds,ax                 ; 32 bytes for Alchemy Header
  242.          mov     si,32                 ; palette offset
  243.          mov     es,ax
  244.          mov     di,32
  245.  
  246.          mov     cx,768                ; 256*3 components
  247. @@:      lodsb
  248.          shr     al,2                  ; 8 to 6 bits conversion
  249.          stosb
  250.          dec     cx
  251.          jnz     @B
  252.  
  253.          pop     es
  254.          pop     ds
  255.  
  256.  
  257. ;---------------
  258.  
  259.          mov     ah,48h                ; MALLOC
  260.          mov     bx,(65535 SHR 4)+1    ; memory requested
  261.          int     21h
  262.          mov     TabSeg,ax             ; Segment address returned
  263.  
  264. ; do precalculations   (calculer table des courbes !!!)
  265.  
  266.          mov     ax,TabSeg             ; my table
  267.          mov     es,ax
  268.          xor     di,di
  269.          mov     bx,-256               ; amplitude de base
  270.          mov     cx,256                ; 256 courbes (curves)
  271. EVEN        
  272. looper:
  273.          mov     si,OFFSET _SinusTbl   ; Sine table
  274.          push    cx
  275.          mov     cx,256                ; 256 valeurs/courbe
  276. @@:
  277.          lodsw
  278.          imul    bx                    ; * amplitude
  279.          mov     al,ah                 ; normaliser
  280.          sal     al,1
  281.          stosb                         ; sauver valeur
  282.          dec     cx                    ; loop    @B
  283.          jnz     @B
  284.          pop     cx
  285.          add     bx,2                  ; calculer amplitude suivante
  286.          dec     cx                    ; loop    looper
  287.          jnz     looper
  288.  
  289. ;---------------
  290.  
  291.          STARTUP
  292.  
  293. ;---- wait right position/row in tune ----
  294.  
  295. WaitPos: 
  296.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  297.          
  298.          les     bx,DWORD PTR[_MP]
  299.          push    ds
  300.          push    OFFSET _ReplayInfo
  301.  
  302.          ; _MP->GetInformation(&ReplayInfo)
  303.  
  304.          call    (ModulePlayer PTR es:[bx]).GetInformation
  305.          add     sp,4
  306.  
  307.          mov     ax,_ReplayInfo.pos
  308.          shl     eax,14
  309.          or      ax,_ReplayInfo.row
  310.          or      ah,al
  311.          shr     eax,8 
  312.          cmp     ax,WORD PTR[DebSong]  ; is it time ????
  313.          jb      WaitPos
  314.  
  315.          xor     eax,eax   
  316. ;------------------------------------------
  317.  
  318.          mov     Termine,0 ; pas encore terminer !!!
  319.  
  320.  
  321.          mov     _FadeON,0
  322.          mov     FadeFlag,0
  323.          mov     FadePtr1,OFFSET _WhitePal ;_BlackPal  ; Black to pic for the beginning !!!
  324.          mov     ax,ds
  325.          mov     FadePtr1+2,ax
  326.          mov     FadePtr2,32
  327.          mov     ax,Picseg
  328.          mov     FadePtr2+2,ax
  329. ;         mov     ax,_FrameCounter
  330. ;         mov     Delai,ax
  331.          mov     _FrameCounter,0
  332.          mov     Delai,0
  333.  
  334.          cmp     _VGAcompatible,0
  335.          je      NoCompatible      ; if card doesn't support 7-mode technology
  336.  
  337. ;==================== VGA compatible code =====================
  338. ;        works in 7-mode technology --> hardware pixel doubling (fast!)
  339.  
  340.  
  341.          mov     bx,_StartAdr
  342.          mov     WORD PTR[bx],Screen1   ; _StartAdr->base = 0
  343.          mov     WORD PTR[bx+2],0       ; _StartAdr->flag = false
  344.          mov     bx,_WorkAdr
  345.          mov     WORD PTR[bx],Screen2   ; _WorkAdr->base
  346.          mov     WORD PTR[bx+2],0       ; _WorkAdr->flag = false
  347.          mov     bx,_NextAdr
  348.          mov     WORD PTR[bx],Screen3   ; _NextAdr->base
  349.          mov     WORD PTR[bx+2],0       ; _NextAdr->flag = false
  350.          mov     _Triple,1              ; triple buffering
  351.          VSYNC
  352.  
  353. EVEN
  354. MainTransf: ; -= VSYNC =-
  355.  
  356. ;***** 2nd page *****
  357. Do_a_frame:
  358.          mov  di,_WorkAdr
  359.          cmp  WORD PTR[di+2],1 ; _WorkAdr->flag true (previous _NextAdr) ?
  360.          je   NextFrame        ; then construct next frame
  361.  
  362.          mov  Dest,di          ; save pointer
  363.  
  364.          NEXTSTEP              ; new step !!!
  365.  
  366.          mov     cx,CurStep    ; nombre de VBLs perdues...
  367. @@:                            ; (incrementer suivant le nb de VBLs)
  368.          add     Yptr,6        ; pointeur sinus vertical (moving)
  369.          and     Yptr,1023
  370.          add     Xptr,4        ; pointeur sinus horizontal (moving)
  371.          and     Xptr,1023
  372.          add     XSptr,8       ; pointeur sinus horizontal (scaling)
  373.          and     XSptr,1023
  374.          inc     cs:[Patchon+1]
  375.          and     cs:[Patchon+1],255
  376.  
  377.          dec     cx            ; loop    @B
  378.          jnz     @B
  379.  
  380.          cmp     FadeFlag,255
  381.          jb      NewFade
  382.  
  383.          cmp     Termine,1    ; Terminer si dernier fade fini
  384.          je      GoOutTransf
  385.  
  386.          mov     _FadeON,0    ; don't set _TmpPal anymore ...
  387.          jmp     @F
  388. NewFade: mov     ax,FadeFlag  ; average Black-MyPal
  389.          push    ax
  390.          push    ds
  391.          push    OFFSET _TmpPal
  392.          mov     ax,FadePtr1+2
  393.          push    ax         
  394.          mov     ax,FadePtr1
  395.          push    ax
  396.          mov     ax,FadePtr2+2 
  397.          push    ax
  398.          mov     ax,FadePtr2
  399.          push    ax
  400.          call    _AveragePAL
  401.          add     sp,7*2
  402.          mov     _FadeON,1            ; set new PAL during next VR !!!!
  403.          mov     cx,CurStep
  404.          sub     cx,Delai             ; temps chargement
  405.          mov     Delai,0              ; plus delai ....
  406.          test    cx,cx
  407.          jnz     Faddi
  408.          inc     cx
  409. Faddi:   add     FadeFlag,4           ; inc fade ..
  410.          dec     cx
  411.          jnz     Faddi
  412. @@:
  413.  
  414. ;----------- test if we must finish ... ----------
  415.  
  416.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  417.          
  418.          les     bx,DWORD PTR[_MP]
  419.          push    ds
  420.          push    OFFSET _ReplayInfo
  421.  
  422.          ; _MP->GetInformation(&ReplayInfo)
  423.  
  424.          call    (ModulePlayer PTR es:[bx]).GetInformation
  425.          add     sp,4
  426.  
  427.          mov     ax,_ReplayInfo.pos
  428.          shl     eax,14
  429.          or      ax,_ReplayInfo.row
  430.          or      ah,al
  431.          shr     eax,8
  432.  
  433.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  434.          jb      @F                      ; to fade off ???
  435.  
  436.          mov     Termine,1
  437.  
  438.          cmp     FadePtr2,OFFSET _BlackPal
  439.          je      @F
  440.          mov     FadeFlag,0
  441.          mov     eax,DWORD PTR[FadePtr2]
  442.          mov     DWORD PTR[FadePtr1],eax   ; fade to black !!!!
  443.          mov     ax,ds
  444.          mov     FadePtr2+2,ax
  445.          mov     FadePtr2,OFFSET _BlackPal
  446.  
  447. @@:      xor     eax,eax
  448. ;--------------------------------------------------------------------
  449.  
  450.          SHOWTIME 48
  451.  
  452.          SHOWTIME 32
  453.  
  454.          call    Transf_It   ; map the MAP !!!
  455.  
  456.          mov    di,_NextAdr
  457.  
  458.          mov    bx,Dest
  459.          mov    WORD PTR[bx+2],1     ; _WorkAdr->flag = true
  460.  
  461.          SHOWTIME 0
  462.  
  463.          jmp  Nexxxt
  464.  
  465. ;******** 3rd page *********
  466. NextFrame:
  467.          mov  di,_NextAdr
  468.          cmp  WORD PTR[di+2],1 ; _NextAdr true ?
  469.          je   NextFrame
  470.     
  471. Nexxxt:
  472.          mov  Dest,di          ; save pointer
  473.  
  474.          NEXTSTEP              ; new step !!!!
  475.  
  476.          mov     cx,CurStep    ; nombre de VBLs perdues...
  477. @@:                            ; (incrementer suivant le nb de VBLs)
  478.          add     Yptr,6        ; pointeur sinus vertical (moving)
  479.          and     Yptr,1023
  480.          add     Xptr,4        ; pointeur sinus horizontal (moving)
  481.          and     Xptr,1023
  482.          add     XSptr,8       ; pointeur sinus horizontal (scaling)
  483.          and     XSptr,1023
  484.          inc     cs:[Patchon+1]
  485.          and     cs:[Patchon+1],255
  486.  
  487.          dec     cx            ; loop    @B
  488.          jnz     @B
  489.  
  490.          cmp     FadeFlag,255
  491.          jb      NewFade2
  492.  
  493.          cmp     Termine,1    ; Terminer si dernier fade fini
  494.          je      GoOutTransf
  495.  
  496.          mov     _FadeON,0    ; don't set _TmpPal anymore ...
  497.          jmp     @F
  498. NewFade2:mov     ax,FadeFlag  ; average Black-MyPal
  499.          push    ax
  500.          push    ds
  501.          push    OFFSET _TmpPal
  502.          mov     ax,FadePtr1+2
  503.          push    ax         
  504.          mov     ax,FadePtr1
  505.          push    ax
  506.          mov     ax,FadePtr2+2 
  507.          push    ax
  508.          mov     ax,FadePtr2
  509.          push    ax
  510.          call    _AveragePAL
  511.          add     sp,7*2
  512.          mov     _FadeON,1            ; set new PAL during next VR !!!!
  513.          mov     cx,CurStep
  514.          sub     cx,Delai             ; temps chargement
  515.          mov     Delai,0              ; plus delai ....
  516.          test    cx,cx
  517.          jnz     Faddi2
  518.          inc     cx
  519. Faddi2:  add     FadeFlag,4           ; inc fade ..
  520.          dec     cx
  521.          jnz     Faddi2
  522. @@:
  523.  
  524. ;----------- test if we must finish ... ----------
  525.  
  526.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  527.          
  528.          les     bx,DWORD PTR[_MP]
  529.          push    ds
  530.          push    OFFSET _ReplayInfo
  531.  
  532.          ; _MP->GetInformation(&ReplayInfo)
  533.  
  534.          call    (ModulePlayer PTR es:[bx]).GetInformation
  535.          add     sp,4
  536.  
  537.          mov     ax,_ReplayInfo.pos
  538.          shl     eax,14
  539.          or      ax,_ReplayInfo.row
  540.          or      ah,al
  541.          shr     eax,8
  542.  
  543.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  544.          jb      @F                      ; to fade off ???
  545.  
  546.          mov     Termine,1
  547.  
  548.          cmp     FadePtr2,OFFSET _BlackPal
  549.          je      @F
  550.          mov     FadeFlag,0
  551.          mov     eax,DWORD PTR[FadePtr2]
  552.          mov     DWORD PTR[FadePtr1],eax   ; fade to black !!!!
  553.          mov     ax,ds
  554.          mov     FadePtr2+2,ax
  555.          mov     FadePtr2,OFFSET _BlackPal
  556.  
  557. @@:      xor     eax,eax
  558. ;--------------------------------------------------------------------
  559.  
  560.          SHOWTIME 48
  561.  
  562.          SHOWTIME 32
  563.  
  564.          call    Transf_It   ; map the MAP
  565.  
  566.          mov    bx,Dest
  567.          mov    WORD PTR[bx+2],1     ; _WorkAdr->flag = true
  568.  
  569.          SHOWTIME 0
  570.  
  571.          LOOP_UNTIL_KEY MainTransf
  572.  
  573.          jmp     GoOutTransf
  574.  
  575. ;===============================================================
  576.  
  577. ;===================== No VGA compatible code ==================
  578.  
  579. NoCompatible:  ; works in standard 320 width --> software pixel doubling (slow)
  580.  
  581.          mov     bx,_StartAdr
  582.          mov     WORD PTR[bx],Screen1   ; _StartAdr->base = 0
  583.          mov     bx,_WorkAdr
  584.          mov     WORD PTR[bx],Screen2*2 ; _WorkAdr->base
  585.          mov     WORD PTR[bx+2],0       ; _WorkAdr->flag = false
  586.          mov     _Triple,0              ; triple buffering
  587.          mov     _SyncFlag,1
  588.          VSYNC
  589.  
  590. EVEN
  591. BMainTransf: ; -= VSYNC =-
  592.  
  593. wait_for_VBL:                       ; wait for Sync Flag
  594.          cmp     _SyncFlag,1
  595.          jne      wait_for_VBL
  596.          mov     _SyncFlag,0
  597.  
  598.          NEXTSTEP                   ; new step !!!
  599.  
  600.          mov     cx,CurStep         ; nombre de VBLs perdues...
  601. @@:                           ; (incrementer suivant le nb de VBLs)
  602.          add     Yptr,6       ; pointeur sinus vertical (moving)
  603.          and     Yptr,1023
  604.          add     Xptr,4       ; pointeur sinus horizontal (moving)
  605.          and     Xptr,1023
  606.          add     XSptr,8      ; pointeur sinus horizontal (scaling)
  607.          and     XSptr,1023
  608.          inc     cs:[BPatchon+1]
  609.          and     cs:[BPatchon+1],255
  610.  
  611.          dec     cx           ; loop    @B
  612.          jnz     @B
  613.  
  614.          cmp     FadeFlag,255
  615.          jb      BNewFade
  616.  
  617.          cmp     Termine,1    ; Terminer si dernier fade fini
  618.          je      GoOutTransf
  619.  
  620.          mov     _FadeON,0    ; don't set _TmpPal anymore ...
  621.          jmp     @F
  622. BNewFade:mov     ax,FadeFlag  ; average Black-MyPal
  623.          push    ax
  624.          push    ds
  625.          push    OFFSET _TmpPal
  626.          mov     ax,FadePtr1+2
  627.          push    ax         
  628.          mov     ax,FadePtr1
  629.          push    ax
  630.          mov     ax,FadePtr2+2 
  631.          push    ax
  632.          mov     ax,FadePtr2
  633.          push    ax
  634.          call    _AveragePAL
  635.          add     sp,7*2
  636.          mov     _FadeON,1            ; set new PAL during next VR !!!!
  637.          mov     cx,CurStep
  638.          sub     cx,Delai             ; temps chargement
  639.          mov     Delai,0              ; plus delai ....
  640.          test    cx,cx
  641.          jnz     BFaddi
  642.          inc     cx
  643. BFaddi:  add     FadeFlag,4           ; inc fade ..
  644.          dec     cx
  645.          jnz     BFaddi
  646. @@:
  647.  
  648. ;----------- test if we must finish ... ----------
  649.  
  650.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  651.          
  652.          les     bx,DWORD PTR[_MP]
  653.          push    ds
  654.          push    OFFSET _ReplayInfo
  655.  
  656.          ; _MP->GetInformation(&ReplayInfo)
  657.  
  658.          call    (ModulePlayer PTR es:[bx]).GetInformation
  659.          add     sp,4
  660.  
  661.          mov     ax,_ReplayInfo.pos
  662.          shl     eax,14
  663.          or      ax,_ReplayInfo.row
  664.          or      ah,al
  665.          shr     eax,8
  666.  
  667.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  668.          jb      @F                      ; to fade off ???
  669.  
  670.          mov     Termine,1
  671.  
  672.          cmp     FadePtr2,OFFSET _BlackPal
  673.          je      @F
  674.          mov     FadeFlag,0
  675.          mov     eax,DWORD PTR[FadePtr2]
  676.          mov     DWORD PTR[FadePtr1],eax   ; fade to black !!!!
  677.          mov     ax,ds
  678.          mov     FadePtr2+2,ax
  679.          mov     FadePtr2,OFFSET _BlackPal
  680.  
  681. @@:      xor     eax,eax
  682. ;--------------------------------------------------------------------
  683.  
  684.          SHOWTIME 48
  685.  
  686.          SHOWTIME 32
  687.  
  688.          mov    di,_WorkAdr
  689.          mov    Dest,di
  690.  
  691.          call   BTransf_It          ; map the MAP !!!
  692.  
  693.          mov    bx,_WorkAdr
  694.          mov    WORD PTR[bx+2],1     ; _WorkAdr->flag = true
  695.  
  696.          SHOWTIME 0
  697.  
  698.          LOOP_UNTIL_KEY BMainTransf
  699.  
  700. ;===============================================================
  701.  
  702.  
  703.  
  704. GoOutTransf:
  705.  
  706.         FLUSH_KEYBUF                  ; Flush keyboard buffer !!! ;-)
  707.  
  708.         mov     _FadeON,0             ; to be sure ....
  709.  
  710. ;----- EXIT -----
  711.  
  712.         STARTUP
  713.  
  714.         mov     ax,TabSeg             ; segment to free
  715.         mov     es,ax
  716.         mov     ah,49h                ; MFREE
  717.         int     21h
  718.  
  719.         mov     ax,Picseg             ; idem ...
  720.         mov     es,ax
  721.         mov     ah,49h
  722.         int     21h
  723.  
  724.         popad
  725.         nop
  726.         ret
  727.  
  728. Transf ENDP
  729.  
  730.  
  731. ;==============================================================================
  732.  
  733. ;----------------- 7-mode algorithm --> hardware pixel doubling ---------------
  734.  
  735. ALIGN
  736. EVEN
  737. Transf_It PROC NEAR                   ; mouvement transformation
  738.  
  739. YSINE TEXTEQU <1234h>
  740.  
  741.         push    ds
  742.  
  743. ; patcher sinus vertical (moving) !!!!
  744.         mov     si,OFFSET _SinusTbl    ; base sinus !
  745.         add     si,Yptr                ; + offset
  746.         mov     di,OFFSET patchmoi+8   ; 1er patch !
  747.         xor     dx,dx
  748.         mov     cx,Windowx/2           ; pour tous les mov al,[bx+...]
  749. EVEN
  750. @@:
  751.         lodsw                          ; charger sinus*256
  752.         sal     ax,8
  753.         xor     al,al
  754.         add     ax,dx
  755.         inc     dx
  756.         mov     cs:[di],ax             ; poker dans le code
  757.         add     di,9
  758.         lodsw
  759.         sal     ax,8
  760.         xor     al,al
  761.         add     ax,dx
  762.         inc     dx
  763.         mov     cs:[di],ax
  764.         add     di,11                  ; patcher les offsets dans le code !
  765.         dec     cx                     ; loop    @B
  766.         jnz     @B
  767.  
  768. ; patcher sinus horizontal (scaling) !!!!
  769.         mov     si,OFFSET _SinusTbl    ; base sinus !
  770.         add     si,XSptr               ; + offset
  771.         mov     di,OFFSET patchmoi+8   ; 1er patch !
  772.         mov     cx,Windowx/2           ; pour tous les mov al,[bx+...]
  773. EVEN
  774. @@:     lodsw                          ; charger sinus*256
  775.         sar     ax,1
  776.         add     cs:[di],ax             ; poker dans le code
  777.         add     di,9
  778.         lodsw
  779.         sar     ax,1
  780.         add     cs:[di],ax
  781.         add     di,11                  ; patcher les offsets dans le code !
  782.         dec     cx                     ; loop    @B
  783.         jnz     @B
  784.  
  785. ; 2D plasming
  786.  
  787.         mov     ax,0a000h             ; Screen base
  788.         mov     es,ax
  789.         mov     di,Dest               ; offset 0 (Screen)
  790.         mov     di,WORD PTR[di]
  791.         shl     di,2                  ; *4
  792.         mov     ax,PicSeg             ; Picture base
  793.         add     ax,(768+32) SHR 4     ; Skip Alchemy header
  794.         mov     gs,ax
  795.         mov     ax,TabSeg             ; Curves table segment
  796.         mov     ds,ax
  797.     
  798.  
  799.         mov     cx,Windowy            ; 67 lines
  800. Patchon LABEL WORD
  801.         mov     si,0000h
  802.         add     si,256*(256-Windowy)/4
  803.  
  804. EVEN
  805. Fill:
  806. Patchmoi LABEL WORD
  807.         REPT   Windowx/2
  808.         lodsw
  809.         mov    bh,al
  810.         mov    bl,bh
  811.         mov    al,gs:[bx+YSINE]
  812.         mov    bh,ah
  813.         mov    bl,bh
  814.         mov    ah,gs:[bx+YSINE]
  815.         stosw
  816.         ENDM
  817.  
  818.         IF (Larg-Windowx) NE 0
  819.            add di,Larg-Windowx
  820.         ENDIF
  821.  
  822.         add    si,256-Windowx
  823.  
  824.         dec    cx
  825.         jnz    Fill
  826.  
  827.         pop     ds
  828.  
  829.         ret
  830.  
  831. Transf_It ENDP
  832.  
  833. ;----------- No VGA compatible algorithm --> software pixel doubling -----------
  834.  
  835. ALIGN
  836. EVEN
  837. BTransf_It PROC NEAR                   ; mouvement transformation
  838.  
  839. YSINE TEXTEQU <1234h>
  840.  
  841.         push    ds
  842.  
  843. ; patcher sinus vertical (moving) !!!!
  844.         mov     si,OFFSET _SinusTbl    ; base sinus !
  845.         add     si,Yptr                ; + offset
  846.         mov     di,OFFSET Bpatchmoi+8  ; 1er patch !
  847.         xor     dx,dx
  848.         mov     cx,Windowx             ; pour tous les mov al,[bx+...]
  849. EVEN
  850. @@:
  851.         lodsw                          ; charger sinus*256
  852.         sal     ax,8
  853.         xor     al,al
  854.         add     ax,dx
  855.         inc     dx
  856.         mov     cs:[di],ax             ; poker dans le code
  857.         add     di,13
  858.         dec     cx
  859.         jnz     @B
  860.  
  861. ; patcher sinus horizontal (scaling) !!!!
  862.         mov     si,OFFSET _SinusTbl    ; base sinus !
  863.         add     si,XSptr               ; + offset
  864.         mov     di,OFFSET Bpatchmoi+8  ; 1er patch !
  865.         mov     cx,Windowx             ; pour tous les mov al,[bx+...]
  866. EVEN
  867. @@:     lodsw                          ; charger sinus*256
  868.         sar     ax,1
  869.         add     cs:[di],ax             ; poker dans le code
  870.         add     di,13
  871.         dec     cx
  872.         jnz     @B
  873.  
  874. ; 2D plasming
  875.  
  876.         mov     ax,0a000h             ; Screen base
  877.         mov     es,ax
  878.         mov     di,Dest               ; offset 0 (Screen)
  879.         mov     di,WORD PTR[di]
  880.         shl     di,2                  ; *4
  881.         mov     ax,PicSeg             ; Picture base
  882.         add     ax,(768+32) SHR 4     ; Skip Alchemy header
  883.         mov     gs,ax
  884.         mov     ax,TabSeg             ; Curves table segment
  885.         mov     ds,ax
  886.     
  887.  
  888.         mov     cx,Windowy            ; 70 lines
  889. BPatchon LABEL WORD
  890.         mov     si,0000h
  891.         add     si,256*(256-Windowy)/4
  892.  
  893. EVEN
  894. BFill:
  895. BPatchmoi LABEL WORD
  896.         REPT   Windowx
  897.         lodsb
  898.         mov    bh,al
  899.         mov    bl,bh
  900.         mov    al,gs:[bx+YSINE]
  901.         mov    ah,al
  902.         stosw
  903.         ENDM
  904.  
  905.         IF (Larg-Windowx) NE 0
  906.            add di,(Larg-Windowx)*2
  907.         ENDIF
  908.  
  909.         add    si,256-Windowx
  910.  
  911.         dec    cx
  912.         jnz    BFill
  913.  
  914.         pop     ds
  915.  
  916.         ret
  917.  
  918. BTransf_It ENDP
  919.  
  920.  
  921. ;==============================================================================
  922.  
  923. TRANS_TEXT ENDS
  924.  
  925.      END
  926.  
  927.